package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.InviteDetailActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.InviteDataBean;
import com.fancy.learncenter.bean.PullResumeDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/4/25.
 */

public class PullResumeAdapter extends CommonRecycleViewAdapter<PullResumeDataBean> {
    public PullResumeAdapter(Context mContext, ArrayList<PullResumeDataBean> itemDatas) {
        super(mContext, R.layout.activity_invite_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final PullResumeDataBean item, int position) {

        TextView work_name = customViewHold.getView(R.id.work_name);
        work_name.setText(item.getRecruit().getPosition());

        TextView price = customViewHold.getView(R.id.price);
        price.setText(item.getRecruit().getSalary_name());

        TextView location = customViewHold.getView(R.id.location);
        location.setText(item.getRecruit().getLocation_name());

        TextView work_education = customViewHold.getView(R.id.work_education);
        work_education.setText(item.getRecruit().getEducation_name());

        TextView work_experience = customViewHold.getView(R.id.work_experience);
        work_experience.setText(item.getRecruit().getWorkyear_name());

        TextView company_name = customViewHold.getView(R.id.company_name);
        company_name.setText(item.getRecruit().getCompany_name());

        SimpleDraweeView company_logo = customViewHold.getView(R.id.company_logo);
        company_logo.setImageURI(item.getRecruit().getCompany_logo());

        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, InviteDetailActivity.class);
                intent.putExtra("recruitId", item.getRecruit_id());
                mContext.startActivity(intent);
            }
        });
//
        TextView delete = customViewHold.getView(R.id.delete);
        if (onclickCallBack != null) {
            delete.setVisibility(View.VISIBLE);
//            delete.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    onclickCallBack.delete(item);
//                }
//            });
        } else {
            delete.setVisibility(View.GONE);
        }

    }

    private InviteAdapter.OnclickCallBack onclickCallBack;

    public InviteAdapter.OnclickCallBack getOnclickCallBack() {
        return onclickCallBack;
    }

    public void setOnclickCallBack(InviteAdapter.OnclickCallBack onclickCallBack) {
        this.onclickCallBack = onclickCallBack;
    }

    public interface OnclickCallBack {
        abstract void delete(InviteDataBean item);
    }
}
